<?php
namespace app\common\model;

class Qqjob extends Base
{
    public static function findByType($type, $uin)
    {
        $self = new static();
        if ($self
            ->where([
                'type' => $type,
                'qq' => $uin,
                'zid' => WEB_ID
            ])
            ->find()) {
            return true;
        } else {
            return false;
        }
    }

    public static function cyAllById($uin, $id)
    {
        $self = new static();
        $count = $self
            ->where([
                'qq' => $uin,
                'gnid' => $id,
                'zid' => WEB_ID
            ])
            ->count();
        if ($count == 14) {
            return true;
        } else {
            return false;
        }
    }

    public static function isAddGnList($uin)
    {
        $self = new static();
        $count = $self
            ->where([
                'qq' => $uin,
                'zid' => WEB_ID
            ])
            ->count();
        if ($count == 1) {
            return true;
        } else {
            return false;
        }
    }

    public static function qdAllById($uin, $id)
    {
        $self = new static();
        $count = $self
            ->where([
                'qq' => $uin,
                'gnid' => $id,
                'zid' => WEB_ID
            ])
            ->count();
        if ($count == 9) {
            return true;
        } else {
            return false;
        }
    }

    public static function myAddGnList($uin)
    {
        $self = new static();
        $all_list = $self
            ->where('qq', '=', $uin)
            ->where('zid', '=', WEB_ID)
            ->order('ph asc')
            ->select();
        return $all_list;
    }

    public static function newMzqq()
    {
        $self = new static();
        $all_list = $self
            ->where([
                'type' => 'zan',
                'start' => 1,
                'zid' => WEB_ID
            ])
            ->order('lasttime desc')
            ->limit(10)
            ->select();
        return $all_list;
    }

    public static function mzphb()
    {
        $self = new static();
        $all_list = $self
            ->where('type', '=', 'zan')
            ->where('zid', '=', WEB_ID)
            ->order('times desc')
            ->limit(10)
            ->select();
        return $all_list;
    }

    public static function allSiteMzNum()
    {
        $self = new static();
        $all_data = $self
            ->where('type', '=', 'zan')
            ->where('zid', '=', WEB_ID)
            ->sum('times');
        return $all_data;
    }
	
	public static function QqMzNum($qq)
    {
        $self = new static();
        $all_data = $self
            ->where('type', '=', 'zan')
			->where('qq', '=', $qq)
            ->where('zid', '=', WEB_ID)
            ->sum('times');
        return $all_data;
    }
	
	public static function allSiteMpNum()
    {
        $self = new static();
        $all_data = $self
            ->where('type', '=', 'reply')
            ->where('zid', '=', WEB_ID)
            ->sum('times');
        return $all_data;
    }

    public static function delByqid($id)
    {
        $self = new static();
        $self->where('qid', '=', $id)->delete();
        return true;
    }
}